package com.example.demo1.wyy.service.impl;

import com.example.demo1.wyy.model.LegalPerson;
import com.example.demo1.wyy.model.vo.LegalPersonAddVo;
import com.example.demo1.wyy.repository.LegalPersonReposirtory;
import com.example.demo1.wyy.service.LegalPersonPlantService;
import com.example.demo1.wyy.util.Result;
import com.example.demo1.wyy.util.ResultVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class LegalPersonPlantServiceImpl implements LegalPersonPlantService {
    @Autowired
    private LegalPersonReposirtory legalPersonReposirtory;


    @Transactional
    public Result<LegalPersonAddVo> addLegalPerson(LegalPersonAddVo legalPersonAddVo) {
        LegalPerson legalPerson = new LegalPerson();

        BeanUtils.copyProperties(legalPersonAddVo,legalPerson);
        legalPersonReposirtory.save(legalPerson);
        System.out.println(legalPerson.getId());
        return ResultVO.success(legalPersonAddVo);
    }
}
